package aml.runtime;

import java.util.List;

import aml.parse.ParseNode;

public class Array extends Value {

	private Context context;
	private List<ParseNode> children;

	public Array(Context ctx, List<ParseNode> nodes) {
		context = ctx;
		children = nodes;
		
		slots.put("size", new Method() {
			@Override
			public Value apply(Context ctx, Value[] args) {
				return toNum();
			}
		});
	}
	
	public Context getContext() {
		return context;
	}
	
	public List<ParseNode> getChildren() {
		return children;
	}

	@Override
	public ValueNum toNum() {
		return new ValueNum(children.size());
	}

}
